package com.mz.ozy.mvp.presenter;


import android.app.Activity;

import com.mz.ozy.base.BasePresenterImpl;
import com.mz.ozy.bean.AssetsBean;
import com.mz.ozy.mvp.model.AssetsModel;
import com.mz.ozy.mvp.view.AssetsContract;
import com.mz.ozy.net.MyObserver;
import com.mz.ozy.utils.RxUtil;

import org.json.JSONObject;

import okhttp3.ResponseBody;

/**
 * Created by administrator on 2018/12/3.
 */
public class AssetsPresenter extends BasePresenterImpl<AssetsContract.View> implements AssetsContract.Presenter{

    private AssetsModel mModel;

    public AssetsPresenter(){
        mModel = new AssetsModel();
    }


    @Override
    public void geAssetsInfo(Activity activity, boolean isShow) {
        mModel.geAssetsInfo(activity)
                .compose(RxUtil.rxSchedulerHelper(mView.<ResponseBody>bindToLifecycle()))
                .subscribe(new MyObserver<AssetsBean>(mView,isShow){
                    @Override
                    public void onSuccesss(AssetsBean bean) {
                        mView.geAssetsInfoSuccess(bean);
                    }
                });
    }
    @Override
    public void obtainBuyHy(Activity activity, String amount, String password) {
        mModel.obtainBuyHy(activity,amount,password)
                .compose(RxUtil.rxSchedulerHelper(mView.<ResponseBody>bindToLifecycle()))
                .subscribe(new MyObserver<JSONObject>(mView){
                    @Override
                    public void onSuccesss(JSONObject json) {
                        mView.obtainBuyHy(json);
                    }
                });
    }
}
